package com.qf.efserver.sport.controller;


import com.qf.common.core.annotation.NoLoginCheck;
import com.qf.common.core.common.R;
import com.qf.common.core.entity.ActivityRecords;
import com.qf.efserver.sport.param.SportParam;
import com.qf.efserver.sport.service.SportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@Slf4j
@Api(tags = "运动管理")
@RequestMapping("/sport")
public class SportController {
    public final SportService sportService;

    /**
     * 添加运动记录
     * @param sportParam
     * @return
     */

    @PostMapping("/add")
    @ApiOperation(value = "添加运动记录")
    public R addActivityRecords(@RequestBody SportParam sportParam) {
        sportService.addActivityRecords(sportParam);
        return R.ok();
    }
    @GetMapping("/select")
    @ApiOperation(value = "查询运动记录")
    public R<List<ActivityRecords>> selectActivityRecords(@RequestParam Integer timeId) {
        List<ActivityRecords> activityRecords = sportService.selectActivityRecords(timeId);
        return R.ok(activityRecords);
    }

    @GetMapping("/selectWeek")
    @ApiOperation(value = "查询第几周运动次数，当前周：0，上周：1")
    public R<Integer> selectDay(@RequestParam Integer weekId) {
        log.info("查询周运动次数");
        Integer weekCount = sportService.selectWeekCount(weekId);
        return R.ok(weekCount);
    }
}
